package com.lookme.lmtool.cracker.filter.warping;

import com.jhlabs.image.ImageMath;
import com.jhlabs.image.RotateFilter;
import com.lookme.lmtool.cracker.CrackerConstants;
import com.lookme.lmtool.cracker.annotation.FilterAnnotation;
import com.lookme.lmtool.cracker.annotation.ParamAnnotation;
import com.lookme.lmtool.cracker.filter.AbstractFilter;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;

@FilterAnnotation(groupName = CrackerConstants.FILTER_GROUP_NAME_WARPING,name="旋转图像")
public class FilterRotate extends AbstractFilter {
    @XStreamAsAttribute
    @ParamAnnotation(name = "角度", desc = "角度",inputType = ParamAnnotation.InputType.Spinner,amountToStepBy = 0.1)
    float angle=1;


    @Override
    public BufferedImageOp getFilter() {
//        return new RotateFilter(getParamFloatValue("angle")* ImageMath.PI/180,getParamBooleanValue("resize"));
        return new RotateFilter(angle* ImageMath.PI/180);
    }

    @Override
    public BufferedImage filter(BufferedImage src, BufferedImage dst) {
        return getFilter().filter(src, null);
    }
}
